package com.wb.mas.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Copyright (C) 2018,
 * TimeUtils
 * <p>
 * Description
 *
 * @author yue
 * @version 1.0
 * <p>
 * Ver 1.0, 2019-05-05, yue, Create file
 */
public class TimeUtils {

    /**
     * 获取今天后几天的日期
     * @param day
     * @return
     */
    public static String getAfterNowDay(int day){
        SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
        Date beginDate = new Date();
        Calendar date = Calendar.getInstance();
        date.setTime(beginDate);
        date.add(Calendar.DAY_OF_YEAR, day);
        Date endDate = null;
        try {
            endDate = dft.parse(dft.format(date.getTime()));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dft.format(endDate);
    }


    /**
     * 获取现在的时间
     * @return
     */
    public static String getNowDate(){
        SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date nowDate = new Date(System.currentTimeMillis());
        return dft.format(nowDate);
    }

    /**
     * 时间转换
     * @return
     */
    public static String getStringDate(String data){
        SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
        Date nowDate = new Date(Long.valueOf(data));
        return dft.format(nowDate);
    }

}


